<?php

namespace rrx\sdk\work;

use Exception;
use rrx\sdk\RrxApi;

class Application extends RrxApi
{
    protected $config = [];

    private $endpointWorkShareUrl = '/v1/work/getShareUrl';    // 获取活动详情页面地址

    public function __construct($config)
    {
        parent::__construct($config);
        $this->config = $config;
    }

    /**
     * @throws Exception
     */
    public function getShareUrl($h5_guid, $login_id)
    {
        if (empty($h5_guid)) {
            throw new Exception('h5_guid不能为空');
        }
        if (empty($login_id)) {
            throw new Exception('login_id不能为空');
        }

        $params = [
            'app_key' => $this->config['app_key'],
            'h5_guid' => $h5_guid,
            'login_id' => $login_id
        ];
        return $this->sendRequest($this->endpointWorkShareUrl, $params, 'get', false);
    }
}